package avicit.bdp.dds.apc.utils.enums;

import avicit.bdp.core.enums.BaseEnum;

/**
 * @金航数码科技有限责任公司
 * @作者：liyb
 * @邮箱：liyb@avic-digital.com
 * @创建时间： 2021-04-30 15:26
 * @类说明：
 * @修改记录：
 */
public enum ResourceStatus implements BaseEnum {

    UPLOADING(0, "上传中"),
    UPLOAD_SUCCESS(1, "上传成功"),
    UPLOAD_FAIL(2, "上传失败"),
    COMPUTING(3, "计算中"),
    COMPUTE_SUCCESS(4, "计算成功"),
    COMPUTE_FAIL(5, "计算失败");

    private final int code;
    private final String description;

    ResourceStatus(int code, String description){
        this.code = code;
        this.description = description;
    }

    @Override
    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static String getDescByCode(Integer code) {
        if (code != null) {
            ResourceStatus[] values = ResourceStatus.values();
            for (ResourceStatus pythonResStatus : values) {
                if (pythonResStatus.getCode() == code) {
                    return pythonResStatus.getDescription();
                }
            }
        }
        return null;
    }

}
